#include <fstream>

using namespace std;

class Animal {
public:
	virtual void setData(ifstream &ifst) = 0;
	virtual void print(ofstream &ofst) = 0;

	char* getName(){
		return name;
	}

protected:
	char name[15];
};

class Bird: public Animal {
	bool migration;

public:
	void setData(ifstream &ifst);
	void print(ofstream &ofst);

	Bird() {
	}
};

class Fish: public Animal {
	enum Home {
		SEA, LIKE, RIVER, UNKNOW
	};
	Home life;

public:
	void setData(ifstream &ifst);
	void print(ofstream &ofst);

	Fish() {
	}
};

class Creator {
public:
	virtual Animal* doMakeAnimal(int key, ifstream &ifst) = 0;
};

class AnimalCreator: public Creator {
public:
	Animal* doMakeAnimal(int key, ifstream &ifst);
};

class Container {
protected:
	int size;

	struct Element {
		Animal *value;
		Element *next, *previous;
	};

	Element *begin, *end;

public:
	void readFromFile(ifstream &ifst, Creator &animalCreator);
	void print(ofstream &ofst);
	Container() :
			size(0) {
	}
	;

	~Container();
};
